'use strict';


const Controller = require('egg').Controller;

class PostController extends Controller {
    async create() {
        this.ctx.body = {
            code: 123,
            data: "缺少参数"
        };
    }
    async index() {
        console.log("=====")
        const createRule = {
            houseName: {
                type: "string", required: false, allowEmpty: true
            },
            typeId: {
                type: 'string',
            }
        }
        try {
            this.ctx.validate(createRule, this.ctx.query);
<<<<<<< HEAD
            let { houseName, typeId } = this.ctx.query;

            if(houseName != undefined){
                const typeList = await this.ctx.service.getList.getHouseList(houseName, typeId);
                this.ctx.body = {
                    code: 200,
                    data: typeList
                };
            }else{
                this.ctx.body = {
                    code: 403,
                    data:"参数不全"
                };  
            }
=======
            let { houseName, typeId} = this.ctx.query
            const typeList = await this.ctx.service.getList.getHouseList(houseName,typeId);
            console.log(typeList)
            this.ctx.body = {
                code: 200,
                data: typeList
            };
>>>>>>> 732deab553a83bd23ce5ab1d416e1b615a719bfb
        } catch (err) {
            this.ctx.body = {
                code: 404,
                data: [],
                message: "error"
            };
        }

    }
    async show() {
        this.ctx.body = {
            code: 789,
            data: "缺少参数"
        };
    }
}
module.exports = PostController;